package day06;

import java.util.Scanner;

//求平均数
public class CalTotalAvg {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入需要几位评委打分!");
        int n = sc.nextInt();
        double[] arr = calculate(n);
        double avg = avg(arr);
        System.out.println("减去评委的最高和最低的平均值是:"+avg);


    }
    public static double[] calculate(int n){
        double[] scores = new double[n];
        Scanner sc = new Scanner(System.in);
        for (int i=0;i<scores.length;i++){
            System.out.println("第"+(i+1)+"位评委的分数是:");
            scores[i] = sc.nextDouble();
        }
        return scores;
    }
    public static double avg(double[] arr){
        double max = arr[0];
        double min = arr[0];
        double sum = arr[0];
        for (int i =1;i<arr.length;i++){
            sum = sum +arr[i];
            if (arr[i]>max){
                max  = arr[i];
            }
            if (arr[i]<min){
                min = arr[i];
            }
        }
        System.out.println("最高分是:"+max);
        System.out.println("最低分是:"+min);
        return (sum-max-min)/(arr.length-2);

    }
}
